# This is a sample Python script.

# Press ⇧F10 to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
from utils.create_report import CreatReport
from basic_method.run_case import TestCase
import unittest
from common.send_mail import SendMail
from utils.operation_ini import OperationIni


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    suit = unittest.TestSuite()
    suit.addTest(unittest.makeSuite(TestCase))
    rep = CreatReport()
    rep.creat_report(suit)
    msg = f'用例执行总数 {suit.countTestCases()} 条，检查测试成功用例 {TestCase.pass_count} 条， 检查测试失败用例 {TestCase.fill_count} 条'
    send_mail = OperationIni().read_cfg('main', 'mail')
    print(msg)
    if send_mail == 'on':
        report_file = rep.get_report_file()
        mail = SendMail()
        sub = '测试报告'
        # msg = f'用例执行总数 {suit.countTestCases()} 条，检查测试成功用例 {TestCase.pass_count} 条， 检查测试失败用例 {TestCase.fill_count} 条'
        mail.send_mail(sub=sub, msg=msg, file=report_file)





# See PyCharm help at https://www.jetbrains.com/help/pycharm/
